Don't forget that the "last" iterator points "one past".
For your custom objects, always define:
a default constructor
a copy constructor
operator=
operator<
operator==
With the current relase of CodeWarrior, every user-defined struct or class requires a special macro to be used inside an STL container:
struct ContainedObject
{
int a;
};
__MSL_FIX_ITERATORS__ (ContainedObject);
Objects are copied into containers. The original object still exist and may need to be deleted.
If it ain't broke break it. Better to learn how the complier complains when you do know what the fix is.
Don't do relational compares on iterators. Only use == or !=.
Don't forget to match the const/non-constness or iterators and containers.
Watch nested templates--don't let them look like ">>" vector<int, allocator<int> > v;
If you use the HP STL implementation beware of init_page_size in defalloc.h. It allocates 4K for every STL container that is created. This makes sense on UNIX, but it is probably not what a Macintosh programmer wants.